#include <iostream>
#include <cstring>
#include <vector>

using namespace std;

const int MAXN = 1e5 + 10;
vector<int> monsters;
vector<bool> flags;
bool done;
int n, rest, min1, min2, in;

void delmon(int x){
    for(int i = x; i < n; i++){
        monsters[i] = monsters[i + 1];
        flags[i] = flags[i + 1];
    }
}

int main(){
    freopen("duel.in", "r", stdin);
    freopen("duel.out", "w", stdout);
    int not1then2 = true;

    monsters.push_back(MAXN);
    flags.push_back(true);
    cin>>n;
    int l[3];
    for(int i = 1; i <= n; i++){
        cin>>in;
        monsters.push_back(in);
        flags.push_back(false);
        if(in != 1 && in != 2) not1then2 = false;
        else l[monsters[i]]++;
    }
    if(not1then2){
        if(l[1] < l[2]) cout<<l[2];
        else cout<<l[1];
        return 0;
    }
    while(!done){
        done = true;
        min1 = min2 = 0;
        rest = 0;
        for(int i = 1; i <= n; i++) if(monsters[i] < monsters[min1]) min1 = i;
        for(int i = 1; i <= n; i++){
            if((monsters[i] > monsters[min1] && monsters[i] < monsters[min2]) && !flags[i]) min2 = i;
            if(!flags[i])done = false;
        }
        if(min2 == 0) break;
        flags[min2] = true;
        if(monsters[min1] < monsters[min2]){
            delmon(min1);
            monsters.pop_back();
            flags.pop_back();
            n--;
        }
    }
    cout<<n;
    return 0;
}
